﻿using System;
using System.Collections.Generic;

namespace Aludra.Core
{
    internal static class CardPropertyKeyConstants
    {
        public const string Id = "ID";
        public const string Name = "NAME";
        public const string Type = "TYPE";
        public const string Description = "DESCRIPTION";
        public const string Execute = "EXECUTE";
        public const string CanExecute = "CANEXECUTE";
        public const string Attack = "ATTACK";
        public const string Defense = "DEFENSE";
        public const string Attribute = "ATTRIBUTE";
        public const string Level = "LEVEL";
        public const string Rank = "RANK";
        public const string MonsterType = "MONSTERTYPE";
        public const string MonsterCategory = "MONSTERCATEGORY";
        public const string MonsterEffectType = "MONSTEREFFECTTYPE";
		public const string SpellTrapType = "SPELLTRAPTYPE";
    }

    public class CardsLoaderConfiguration
    {
        public string CardArrayKeyword { get; set; }

        private Dictionary<string, string> _cardPropertyMapper;
        public Dictionary<string, string> CardPropertyMapper
        {
            get
            {
                if (_cardPropertyMapper == null)
                {
                    _cardPropertyMapper = GetDefaultPropertyMap();
                }
                return _cardPropertyMapper;
            }
            set { _cardPropertyMapper = value; }
        }

        /// <summary>
        /// Intializes the CardsLoaderConfiguration class with default configurations
        /// </summary>
        public CardsLoaderConfiguration()
        {
            this.CardArrayKeyword = "card";
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cardArrayKeyword"></param>
        /// <exception cref="System.ArgumentNullException"></exception>
        public CardsLoaderConfiguration(string cardArrayKeyword)
        {
            if (cardArrayKeyword == null)
            {
                throw new ArgumentNullException("cardArrayKeyword");
            }
            this.CardArrayKeyword = cardArrayKeyword;
        }

        public static Dictionary<string, string> GetDefaultPropertyMap()
        {
            var map = new Dictionary<string, string>
            {
                {CardPropertyKeyConstants.Id, "id"},
                {CardPropertyKeyConstants.Name, "name"},
                {CardPropertyKeyConstants.Type, "type"},
                {CardPropertyKeyConstants.Description, "desc"},
                {CardPropertyKeyConstants.Execute, "exe"},
                {CardPropertyKeyConstants.CanExecute, "canexe"},
                {CardPropertyKeyConstants.Attack, "atk"},
                {CardPropertyKeyConstants.Attribute, "attr"},
                {CardPropertyKeyConstants.Defense, "def"},
                {CardPropertyKeyConstants.Level, "lv"},
                {CardPropertyKeyConstants.MonsterCategory, "moncate"},
                {CardPropertyKeyConstants.MonsterEffectType, "monetype"},
                {CardPropertyKeyConstants.MonsterType, "montype"},
                {CardPropertyKeyConstants.Rank, "rank"},
				{CardPropertyKeyConstants.SpellTrapType, "sptptype"}
            };
            return map;
        }
    }
}
